#ifndef SYSSERVERSOCKET_H
#define SYSSERVERSOCKET_H

#include "cnsMacroGlobal.h"
#include "framework.h"
#include "server-socket_global.h"
#include <QThread>
#include <uv.h>
#include "serverclientsocketproc.h"
#include "baseproto.h"

class SysServerSocket : public QObject
{
    Q_OBJECT
public:
    Q_INVOKABLE SysServerSocket();
    Q_INVOKABLE void f_run(CnsComponentPtr com, uv_loop_t *loop);
    int server_start(ServerSocketProc* process);
    static void _on_watchdog_timer(uv_timer_t* handle);
    static void _on_connect(uv_stream_t* stream, int status);
    static void close_client(ServerClientSocketProcPtr client);
    int server_initialize(uv_loop_t* loop, ServerSocketProc* server);
    void server_destroy(ServerSocketProc* server);
    Q_INVOKABLE void f_server_detach(ServerSocketProc* server, ServerClientSocketProc* client);
};

Q_DECLARE_METATYPE(SysServerSocket*)

#endif // SYSSERVERSOCKET_H
